﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace cs2335lab5
{
    namespace Data
    {
        [SerializableAttribute]
        public class Issue : INotifyPropertyChanged
        {
            /// <summary>
            /// Delegate to notify GUI that class elements have changed
            /// </summary>
            public event PropertyChangedEventHandler PropertyChanged;

            /// <summary>
            /// Method to notify GUI that class elements have changed
            /// </summary>
            /// <param name="propertyChanged"></param>
            public void NotifyPropertyChanged(string propertyChanged)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyChanged));
                }
            }

            /// <summary>
            /// Public constructor
            /// </summary>
            public Issue()
            {
                IssueStatus = null;
                DueDate = DateTime.MinValue;
                CreationDate = DateTime.MinValue;
            }

            /// <summary>
            /// Unique key for issues
            /// </summary>
            public Int64? ID { get; set; }

            /// <summary>
            /// This issue's name
            /// </summary>
            public string Name { get; set; }

            /// <summary>
            /// A string that provides a detailed description of this issue
            /// </summary>
            public string DetailedDescription { get; set; }

            /// <summary>
            /// A DateTime that tells the creation date of this issue
            /// </summary>
            public DateTime CreationDate { get; set; }

            /// <summary>
            /// A DateTime that tells the due date of this issue
            /// </summary>
            public DateTime DueDate { get; set; }

            /// <summary>
            /// The Data.User that created this issue
            /// </summary>
            public User Creator { get; set; }

            /// <summary>
            /// A Data.User that this issue is assigned to
            /// </summary>
            public User AssignedTo { get; set; }

            /// <summary>
            /// An enumeration that lists the possible status states
            /// </summary>
            public enum Status { NotStarted, InProgress, Completed };

            /// <summary>
            /// The status of the issue
            /// </summary>
            public Status? IssueStatus { get; set; }

            /// <summary>
            /// A decimal of hours worked on this issue
            /// </summary>
            public decimal HoursWorked { get; set; }

            /// <summary>
            /// A decimal of hours remaining on this issue
            /// </summary>
            public decimal HoursToGo { get; set; }

            /// <summary>
            /// Copy constructor
            /// </summary>
            /// <param name="issue"></param>
            public Issue(Data.Issue issue)
            {
                this.AssignedTo = issue.AssignedTo;
                this.CreationDate = issue.CreationDate;
                this.Creator = issue.Creator;
                this.DetailedDescription = issue.DetailedDescription;
                this.DueDate = issue.DueDate;
                this.HoursToGo = issue.HoursToGo;
                this.HoursWorked = issue.HoursWorked;
                this.ID = issue.ID;
                this.IssueStatus = issue.IssueStatus;
                this.Name = issue.Name;
            }
        }
    }
}
